package com.us.usws.site.ws.entity;

import net.iwsh.core.common.GlobalConfig;

public class WSEntityFactory {

	/**
	 * default entity with code=0 and default ver
	 * @param data
	 * @return
	 */
	public static WSEntity getDefaultWSEntity(Object data) {
		WSEntity ret = new WSEntity() {
		};
		ret.setVer(GlobalConfig.getByte("Commons/Ver", (byte) 1));
		ret.setCode((short) 0);

		ret.setData(data);
		return ret;
	}

	/**
	 *  entity with code and data specified
	 * @param code
	 * @param data
	 * @return
	 */
	public static WSEntity getWSEntity(byte code, Object data) {
		WSEntity ret = getDefaultWSEntity(data);
		ret.setCode(code);
		return ret;
	}

	/**
	 * get default entity with records field in it.
	 * @return
	 */
	public static WSEntity getEmptyEntityWithRecords() {
		//pack records
		WSEntityRecords data = new WSEntityRecords();

		WSEntity ret = getDefaultWSEntity(data);
		return ret;
	}

}
